//
//  TextTableViewCell.m
//  CarOfHome2
//
//  Created by 微 醺 on 15/9/24.
//  Copyright (c) 2015年 Frank. All rights reserved.
//

#import "TextTableViewCell.h"

@implementation TextTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.text = [[UILabel alloc] init];
//        self.text.backgroundColor = [UIColor cyanColor];
        [self.contentView addSubview:_text];
    }
    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];

    
    self.text.frame = CGRectMake(20, 0, self.frame.size.width - 20, self.frame.size.height);

    AppDelegate *dele = [[UIApplication sharedApplication]delegate];
    if (dele.isNight == 1) {
        self.contentView.backgroundColor = [UIColor blackColor];
        self.text.textColor = [UIColor whiteColor];
        
    }
    else{
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.text.textColor = [UIColor blackColor];

    }

    self.text.frame = CGRectMake(30 * SAWindth, 0, 315 * SAWindth, [[self class] heightWithText:self.text.text]);
    self.text.numberOfLines = 0;
    self.text.font = [UIFont systemFontOfSize:19];
    self.text.textColor = [UIColor grayColor];
    
}



+ (CGFloat)heightWithText:(NSString *)text
{
    CGRect rect = [text boundingRectWithSize:CGSizeMake(315 * SAWindth, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19]} context:nil];
    return rect.size.height;
}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
